<!DOCTYPE html>
<html>
<head>
<title>代码生成器</title>
<#include "/header.html">
</head>
<body>
	<div id="rrapp">
		<form action="">
			1号柜
			<select id="book_grid_id1">
				<option value="0">正常</option>
				<option value="1">维修</option>
			</select>
			5号柜
			<select id="book_grid_id5">
				<option value="0">正常</option>
				<option value="1">维修</option>
			</select>
			<br/>
			2号柜
			<select id="book_grid_id2">
				<option value="0">正常</option>
				<option value="1">维修</option>
			</select>
			6号柜
			<select id="book_grid_id6">
				<option value="0">正常</option>
				<option value="1">维修</option>
			</select>
			<br/>
			3号柜
			<select id="book_grid_id3">
				<option value="0">正常</option>
				<option value="1">维修</option>
			</select>
			7号柜
			<select id="book_grid_id7">
				<option value="0">正常</option>
				<option value="1">维修</option>
			</select>
			<br/>
			4号柜
			<select id="book_grid_id4">
				<option value="0">正常</option>
				<option value="1">维修</option>
			</select>
			8号柜
			<select id="book_grid_id8">
				<option value="0">正常</option>
				<option value="1">维修</option>
			</select><br/>
			<button onclick="updateBookGridStatus()">提交</button>
			<button onclick="reset()">取消</button>
		</form>
	</div>
</body>
<script type="text/javascript">
var code= GetQueryString("code");
var data = {"code":code};
var book_grid_codes=[];
$.ajax({
	url : baseURL + 'operation/bookShelf/bookgrids',
	type : 'POST',
	contentType : "application/json; charset=utf-8",
	data : JSON.stringify(data),
	dataType : 'json',
	success : function(result) {
		if (result.detail != null) {
			console.log(result.detail);
			for(var i=1,length=result.detail.length;i<=length;i++){
				book_grid_codes[i-1]=result.detail[i-1].bookgridCode;
				var selectObj = document.getElementById("book_grid_id"+i);
				//console.log(result.detail[i-1].damageReport);
				if(result.detail[i-1].damageReport==0){
					selectObj[0].selected = true;
				}else{
					selectObj[1].selected = true;
				}
			}
		} else {
			layer.msg(message, {
				icon : -1
			});
		}
	}
});
function updateBookGridStatus(){
	var book_grid_id1_val = $("#book_grid_id1 option:selected").val();
	var book_grid_id2_val = $("#book_grid_id2 option:selected").val();
	var book_grid_id3_val = $("#book_grid_id3 option:selected").val();
	var book_grid_id4_val = $("#book_grid_id4 option:selected").val();
	var book_grid_id5_val = $("#book_grid_id5 option:selected").val();
	var book_grid_id6_val = $("#book_grid_id6 option:selected").val();
	var book_grid_id7_val = $("#book_grid_id7 option:selected").val();
	var book_grid_id8_val = $("#book_grid_id8 option:selected").val();
	var updateData = {
		"bookGridCode1":book_grid_codes[0],"status1":book_grid_id1_val,
		"bookGridCode2":book_grid_codes[1],"status2":book_grid_id2_val,
		"bookGridCode3":book_grid_codes[2],"status3":book_grid_id3_val,
		"bookGridCode4":book_grid_codes[3],"status4":book_grid_id4_val,
		"bookGridCode5":book_grid_codes[4],"status5":book_grid_id5_val,
		"bookGridCode6":book_grid_codes[5],"status6":book_grid_id6_val,
		"bookGridCode7":book_grid_codes[6],"status7":book_grid_id7_val,
		"bookGridCode8":book_grid_codes[7],"status8":book_grid_id8_val
	};
	$.ajax({
		url : baseURL + 'operation/bookShelf/updateBookGrid',
		type : 'POST',
		contentType : "application/json; charset=utf-8",
		data : JSON.stringify(updateData),
		dataType : 'json',
		success : function(result) {
			console.log(result);
			if (result.detail != null) {
				layer.msg(result.detail.message, {
					icon : -1
				});
			} else {
				layer.msg("修改成功", {
					icon : -1
				});
			}
			
		}
	});
	window.parent.location.reload();
}
</script>
</html>